package com.ant.collect.controller;


import com.ant.collect.common.ResultVo;
import com.ant.collect.dto.DictionaryDto;
import com.ant.collect.service.IDictionaryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hzd
 * @since 2025-10-23
 */
@Api(tags = "数据字典接口")
@RestController
@RequestMapping("/dictionary")
public class DictionaryController {

    @Autowired
    IDictionaryService dictionaryService;

//
//    @ApiOperation(value = "获取所有列表")
//    @GetMapping("/list")
//    public ResultVo list(){
//        return ResultVo.success("ok",dictionaryService.list());
//    }


    @ApiOperation(value = "通列表获取对应的数据结构列表")
    @GetMapping("/listTree")
    @ApiImplicitParam(name = "type", value = "分类名称 1 7大行业 2 国民经济行业 3 辅料类 4 污染指数 5 标准", required = true,dataType = "String", paramType = "query")
    public ResultVo listTree(String type){
        return ResultVo.success("ok",dictionaryService.listTree(type));
    }


    @ApiOperation(value = "保存信息")
    @PostMapping("/save")
    public ResultVo save(@RequestBody DictionaryDto dto)
    {
        return ResultVo.success("添加成功",dictionaryService.saveDictionary(dto));
    }

}
